from __future__ import unicode_literals

from django.db import models

from django.utils import timezone

# Create your models here.

class Post(models.Model):
    '''
    A standard blog post.
    '''
    title = models.CharField(max_length=255)
    content = models.TextField()
    pub_date = models.DateTimeField(default=timezone.now, editable=False)
    last_edited = models.DateTimeField(auto_now=True, blank=True)

    def __unicode__(self):
        return self.title

class Comment(models.Model):
    '''
    A comment to be made on a blog post.
    '''
    author = models.CharField(max_length=255)
    website = models.CharField(max_length=255, blank=True)
    pub_date = models.DateTimeField(default=timezone.now, editable=False)
    content = models.TextField()
    post = models.ForeignKey(Post, on_delete=models.CASCADE)

    def __unicode__(self):
        return u"%s on \"%s\" (%s)" % (self.author, self.post.title, self.pub_date)
